'use strict';

/**
 * @ngdoc function
 * @name webApp.controller:ModifypasswordCtrl
 * @description
 * # ModifypasswordCtrl
 * Controller of the webApp
 */
angular.module('webApp')
  .controller('ModifypasswordCtrl', function ($scope,promiseModifyPassWord,popBox,$location,cookie) {
    $scope.user = [];
    $scope.submit = function(){
      if($scope.user.new_password == $scope.user.new_password_confirmation){
        //修改密码
        promiseModifyPassWord.modifyPassWord($scope.user).then(function(){
          popBox.showConfirm('提示','修改密码成功！');
          $scope.user = [];
          cookie.delCookie('access_token');
          $location.path('/root/signIn');
        });
      }
      else{
        popBox.showConfirm('警告','两次输入密码不一致！');
      }
    };
  });
